package com.neymar.util;

import com.neymar.entity.Log;
import com.neymar.logEnum.ObjectionTypeEnum;
import com.neymar.logEnum.OperationTypeEnum;

/**
 * @author neymar
 * @date 2021-06-06
 * 用来设置日志的类型和返回具体的操作
 */
public class LogUtils {

    public static Log getLogInfo(String userName, int operationType, int objectType) {
        OperationTypeEnum operation = getOperationType(operationType);
        String name = operation.getName();
        ObjectionTypeEnum objection = getObjectType(objectType);
        String object = objection.getName();
        Log log = new Log();
        log.setLogId(RandomID.getLogID());
        log.setUserId(userName);
        log.setLogType(operation.getValue());
        String details = name + "了" + object;
        log.setLogDetail(details);
        return log;
    }

    public static OperationTypeEnum getOperationType(int operationType) {
        OperationTypeEnum enumEnum = null;
        switch (operationType) {
            case 1:
                enumEnum = OperationTypeEnum.ADD;
                break;
            case 2:
                enumEnum = OperationTypeEnum.DELETE;
                break;
            case 3:
                enumEnum = OperationTypeEnum.UPDATE;
                break;
            case 4:
                enumEnum = OperationTypeEnum.QUERY;
                break;


        }
        return enumEnum;
    }

    public static ObjectionTypeEnum getObjectType(int objectType) {
        ObjectionTypeEnum enumEnum = null;
        switch (objectType) {
            case 1:
                enumEnum = ObjectionTypeEnum.RECRUITER;
                break;
            case 2:
                enumEnum = ObjectionTypeEnum.POSITION;
                break;
            case 3:
                enumEnum = ObjectionTypeEnum.PROGRESS;
                break;
            case 4:
                enumEnum = ObjectionTypeEnum.USER;
                break;
            case 5:
                enumEnum = ObjectionTypeEnum.INFO;
                break;
            case 6:
                enumEnum = ObjectionTypeEnum.COMPANY;
                break;
            case 7:
                enumEnum = ObjectionTypeEnum.PROBLEM;
                break;
            case 8:
                enumEnum = ObjectionTypeEnum.EXAM;
                break;

        }
        return enumEnum;
    }
}
